//
//  BaseNC.m
//  CoolJF
//
//  Created by Apple on 2017/2/23.
//  Copyright © 2017年 Ubi. All rights reserved.
//

#import "BaseNC.h"

#define NavBarColor [UIColor colorWithRed:247.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1.0]

@interface BaseNC ()

@end

@implementation BaseNC

+ (void)load
{
    UIBarButtonItem *item = nil;
    UINavigationBar *bar = nil;
    
    NSString *version = [UIDevice currentDevice].systemVersion;
    if (version.doubleValue >= 9.0) {
        // 针对 9.0 以上的iOS系统进行处理
        item=[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[self]];
        bar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[self]];
    } else {
        // 针对 9.0 以下的iOS系统进行处理
         item=[UIBarButtonItem appearanceWhenContainedIn:self, nil];
         bar = [UINavigationBar appearanceWhenContainedIn:self, nil];
    }
   
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    dic[NSFontAttributeName]=[UIFont systemFontOfSize:18];
    dic[NSForegroundColorAttributeName]=[UIColor blackColor];
    [item setTitleTextAttributes:dic forState:UIControlStateNormal];
    
   
    [bar setBackgroundImage:[self imageWithColor:NavBarColor] forBarMetrics:UIBarMetricsDefault];
    NSMutableDictionary *dicBar=[NSMutableDictionary dictionary];
    
    dicBar[NSFontAttributeName]=[UIFont systemFontOfSize:15];
    [bar setTitleTextAttributes:dic]
   
   ;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
 
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    return [super pushViewController:viewController animated:animated];
}



#pragma mark - pravite

+ (UIImage *)imageWithColor:(UIColor *)aColor
{
    CGRect aFrame = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(aFrame.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [aColor CGColor]);
    CGContextFillRect(context, aFrame);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}




@end
